<template>
	<view class="contont">
		<image class="imgone" src="../../static/img/img_bg@3x.png" mode=""></image>
		<image class="imgtwo" src="../../static/img/dl_logo@3x.png" mode=""></image>
		<view
			style="position: relative; 
	width:315px ;
	height: 52px;
	margin-top: 47px;
"
		>
			<input type="number" placeholder="请输入账户" v-model="account" class="tarone" />
		</view>

		<view
			style="position: relative; 
	width:315px ;
	height: 52px;
	margin-top:17px;
	display: flex;
"
		>
			<input type="password" placeholder="请输入密码" v-model="Password" class="tarone" v-show="text == 0" />
			<input type="text" placeholder="请输入密码" v-model="Password" class="tarone" v-show="text == 1" />
			<view
				class=""
				style="width: 30px; height:100%;
display: flex;
align-items: center;
justify-content: center;
	border-bottom: 1px solid #F0F0F0;
	box-sizing: border-box;"
				@click="xian"
			>
				<image src="../../static/img/icon_biyan@3x.png" mode="" class="imgthree" style="width: 16px;height: 7px;" v-show="text == 0" @click="xian"></image>
				<image src="../../static/img/icon_zhengyan@3x.png" mode="" class="imgthree" style="width: 16px;height: 11px;" v-show="text == 1"></image>
			</view>
		</view>
		<view style="text-align: right; color: #042A58;margin-top: 15px;width:315px ;font-size: 13px;display: flex;align-items: center;justify-content: space-between;">
			<view style="color: #888888;">
				用户登陆协议
				<text style="color: #042A58;" @click="Agreement">《用户协议》</text>
			</view>
			<text @click="forget">忘记密码？</text>
		</view>
		<button class="Darbut" style="background-color: #042A58;margin-top: 25px;color: #FFFFFF;" @click="deng">登录</button>
		<button class="Darbut" style="border: 1px solid #042A58;background-color:rgba(255,255,255,0.1); margin-top: 30px;color: ##042A58;" @click="ce">注册</button>
	</view>
</template>

<script>
import { ajax } from '../../api.js';
import { Deiverapis } from '../../Deiverapis.js';
export default {
	data() {
		return {
			account: '',
			Password: '',
			text: 0,
			list: ''
		};
	},
	onLoad() {
		wx.hideHomeButton();
	},
	methods: {
		deng() {
			var that = this;
			if (this.account == '' && this.Password == '') {
				uni.showToast({
					title: '请输入账户密码',
					icon: 'none'
				});
			} else {
				Deiverapis({
					url: '/appdriver/loginsubmit',
					data: {
						phone: this.account,
						password: this.Password
					},
					success: function(res) {
						if (res.data.status == 'OK') {
							uni.setStorageSync('sessionid', res.header['Set-Cookie']);
							ajax({
								url: '/v1/appdriver/user/profile',
								success(res) {
									console.log(res);
									if (res.data.message.authstatus == 2) {
										uni.setStorage({
											key: 'name',
											data: { state: res.data.status, phone: that.account, pass: that.Password },
											success() {
												if (that.list == 1) {
													uni.navigateBack({
														delta: 1
													});
												} else {
													uni.switchTab({
														url: '../Receipt/Receipt'
													});
												}
											}
										});
									} else {
										uni.reLaunch({
											url: '../informations/information?phone=' + that.account + '&&password=' + that.Password
										});
									}
								}
							});
						} else {
							uni.showToast({
								title: '账户密码不正确',
								icon: 'none'
							});
						}
					}
				});
			}
		},
		// 协议
		Agreement() {
			uni.navigateTo({
				url: '../Agreement/Agreement'
			});
		},
		// 忘记密码
		forget() {
			uni.navigateTo({
				url: './forget?id=1'
			});
		},
		ce() {
			uni.navigateTo({
				url: '../registered/registered'
			});
		},
		// 眼睛
		xian() {
			var that = this;

			this.text = 1;
			setTimeout(function() {
				that.text = 0;
			}, 3000);
		}
	}
};
</script>

<style>
page {
	height: 100%;
}
.imgone {
	width: 100%;
	height: 100%;
	position: absolute;
	left: 0;
	top: 0;
	z-index: -1;
}

.imgtwo {
	width: 210px;
	height: 64px;
	margin-top: 40px;
}
.tarone {
	width: 100%;
	height: 100%;
	border-bottom: 1px solid #f0f0f0;
	box-sizing: border-box;
}

.Darbut {
	width: 315px;
	height: 44px;
	border-radius: 8px;
}
</style>
